home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Languages / Masm V6.11 / SAMPLES / NTSAMPLE / NTDLL / ASMDLL.AS$ / ASMDLL.bin
Encoding:
Text File  |  1993-08-17  |  2.6 KB  |  121 lines

  1. ;------------------------------------------------------------------------
  2. ;
  3. ; Asm DLL functions. 
  4. ;
  5. ; Receives: char, short, int, and long passed by value and reference, 
  6. ;
  7. ; Returns: True (1) for success or False (0) for failure
  8. ;
  9. ;------------------------------------------------------------------------
  10.  
  11.  
  12.  
  13. .386                    ; .386 before .model gives 32 bit segments and code.
  14. .model flat, stdcall    
  15.  
  16. .code
  17.  
  18.  
  19. ;
  20. ; Signed integers passed by value.
  21.  
  22. VSIntTest PROC NEAR int1:SBYTE, int2:SDWORD, int3:SWORD, int4:SDWORD
  23.  
  24.   mov al, int1            ; int1 is on the local stack for this proc.
  25.   cmp al, 80h            ; Was the param passed correctly ?
  26.   jne VSError             ; NO, so jump to error handler.
  27.   mov int1, 1           ; YES, modify it on the stack.
  28.  
  29.  
  30.   mov eax, int2            ; do the same here...
  31.   cmp eax, 0ffffffffh
  32.   jne VSError                                          
  33.   mov int2, 1                                          
  34.  
  35.  
  36.   mov ax, int3  
  37.   cmp ax, 7fffh   
  38.   jne VSError
  39.   mov int3, 1
  40.  
  41.  
  42.   mov eax, int4   
  43.   cmp eax, 80000000h
  44.   jne VSError
  45.   mov int4, 1
  46.  
  47.  
  48.   mov eax, 1             ; No errors then return ok.
  49.   jmp VSDone
  50.  
  51. VSError:
  52.   xor eax, eax          ; Errors found then return false.
  53.  
  54. VSDone:
  55.   ret                    ; leave proc.
  56.  
  57. VSIntTest ENDP
  58.  
  59.  
  60. ;
  61. ; Signed integers passed by reference.
  62. ;
  63.  
  64. RSIntTest PROC NEAR int1:DWORD, int2:DWORD, int3:DWORD, int4:DWORD
  65.  
  66.   mov ebx, int1                ; int1 is a 4 byte pointer to a byte, so
  67.   mov al, byte ptr[ebx]     ; move the contents of the address to AL.
  68.   cmp al, 80h               ; Was the pointer param passed correctly ?
  69.   jne RSError                ; NO, so jump to error handler.
  70.   mov byte ptr[ebx], 1         ; YES, we have the address of the param so 
  71.                             ; we'll modify it in the data segment.
  72.  
  73.   mov ebx, int2                ; do the same below...
  74.   mov eax, dword ptr[ebx]                 
  75.   cmp eax, 0ffffffffh
  76.   jne RSError
  77.   mov dword ptr[ebx], 1                   
  78.  
  79.  
  80.   mov ebx, int3
  81.   mov ax, [ebx]
  82.   cmp ax, 7fffh                           
  83.   jne RSError
  84.   mov word ptr[ebx], 1                    
  85.  
  86.  
  87.   mov ebx, int4
  88.   mov eax, dword ptr[ebx]                 
  89.   cmp eax, 80000000h
  90.   jne RSError
  91.   mov dword ptr[ebx], 1                   
  92.  
  93.  
  94.   mov eax, 1                ; No errors then return ok.       
  95.   jmp RSDone
  96.  
  97. RSError:
  98.   xor eax, eax                ; Errors found then return false.
  99.  
  100. RSDone:
  101.   ret                        ; leave proc.
  102.  
  103. RSIntTest ENDP
  104.  
  105.  
  106. ;
  107. ; DllMain is required for all DLL's.
  108. ;
  109.  
  110. DllMain PROC NEAR stdcall    
  111.  
  112.   mov eax, 1                ; Return true to caller. 
  113.  
  114.   ret 12                    ; Cleanup the stack since we don't use any
  115.                               ; of the params passed from the caller. 
  116.  
  117. DllMain ENDP
  118.  
  119. END
  120.